package com.solvePlat.controller;

import com.github.pagehelper.PageInfo;
import com.solvePlat.entity.TopicClassification;
import com.solvePlat.entity.base.BaseResponse;
import com.solvePlat.service.Impl.TopicClassificationServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/topicClassification")
public class TopicClassificationController {
    @Resource
    private TopicClassificationServiceImpl topicClassificationServiceImpl;

    @GetMapping("/selectClassification")
    public BaseResponse selectTopicClassification(TopicClassification topicClassification){

        BaseResponse baseResponse = new BaseResponse();
        try{
           PageInfo  pageInfo =  topicClassificationServiceImpl.selectTopicClassification(topicClassification);
           baseResponse.setData(pageInfo);
           baseResponse.setSuccess(true);
           baseResponse.setMsg("查询成功!");
        }catch (Exception e){
            e.printStackTrace();
            baseResponse.setData("");
            baseResponse.setSuccess(true);
            baseResponse.setMsg("查询失败!");
        }
        return baseResponse;
    }

    @GetMapping("/selectTopicClassificationListByTree")
    public BaseResponse selectTopicClassificationListByTree(TopicClassification topicClassification){
        BaseResponse<List<TopicClassification>> baseResponse = new BaseResponse<List<TopicClassification>>();
        List<TopicClassification> topicClassificationList =  topicClassificationServiceImpl.selectTopicClassificationListByTree(topicClassification);
        baseResponse.setMsg("查询成功!");
        baseResponse.setData(topicClassificationList);
        baseResponse.setSuccess(true);
        return baseResponse;

    }
}
